import java.dyn.MethodHandle;
import java.dyn.MethodHandles;
import java.dyn.MethodType;


public class AttilaInsertBug
{
    public static void main(String[] args) throws Throwable
    {
        MethodHandle xv = MethodHandles.publicLookup().findVirtual(
                AttilaInsertBug.class, "xv", MethodType.make(int.class,
                        int.class, int[].class));
        MethodHandle singleArg = MethodHandles.insertArguments(xv, 2, new int[0]);
        System.out.println("type: " + singleArg.type());
        
        System.out.println(singleArg);
        
        System.out.println(singleArg.invoke(new AttilaInsertBug(), 1));


    }

    // virtual: (AttilaInsertBug, int, int[])int   order: [1, 2, 0]
    // permute: (int[], AttilaInsertBug, int)int
    // insert: (AttilaInsertBug, int)int
    
    // => (int, int[], AttilaInsertBug)int
    // drop: (int, int[])int
    
    // permute order: [1, 2, 0]
    // (AttilaInsertBug, int)int -> (int[], AttilaInsertBug, int)int
    //                           -> (AttilaInsertBug, int, int[])int
    
    
    public int xv(int y, int... z)
    {
        for (int zz : z)
        {
            y += zz;
        }
        return y;
    }
} 